﻿create procedure dbo.DeleteAudiences
(
		@PortalID int
	)

AS

DELETE FROM dbo.AudienceMembers
WHERE     (AudienceId IN
                          (SELECT     dbo.AudienceMembers.AudienceId
                            FROM          dbo.Audience INNER JOIN
                                                   dbo.AudienceMembers ON dbo.Audience.Id = dbo.AudienceMembers.AudienceId
                            WHERE      (dbo.Audience.[SiteID] = @PortalID)))

	DELETE FROM dbo.Audience
	WHERE     ([SiteID] = @PortalID)
	
	/* Ref Integrity deletes children */


